<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Admin\Controller;
use User\Api\UserApi;

/**
 * 后台用户控制器
 * @author 麦当苗儿 <zuojiazi@vip.qq.com>
 */
class ContController extends AdminController {

    /**
     * 用户管理首页
     * @author 麦当苗儿 <zuojiazi@vip.qq.com>
     */
    public function index(){
       $cont = M('contact');

        // var_dump($comp);
        $nickname       =   I('name');
        if(is_numeric($nickname)){
            $map['uid|name']=   array(intval($nickname),array('like','%'.$nickname.'%'),'_multi'=>true);
        }else{
            $map['name']    =   array('like', '%'.(string)$nickname.'%');
        }
        $count =$cont->where($map)->count();// 查询满足要求的总记录数
        
        $Page = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(10)
        $Page->setConfig('prev','上一页');
        $Page->setConfig('next','下一页');
        $Page->setConfig('last','末页');
        $Page->setConfig('first','首页');
        $Page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
        $show = $Page->show();// 分页显示输出
        
        // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $list =$cont ->order('id')->where($map)->limit($Page->firstRow.','.$Page->listRows)->select();
        // 
        // $list   = $this->lists('company', $map);
        int_to_string($list);
        $this->assign('_list', $list);
        $this->assign('page', $show);

        // $this->meta_title = '用户信息';
        $this->display('cont/index');
    }

  
}